package com.example.demo.day.config.learn.design.single.x1;

public class ConfigManger {

    private String fontSize;
    private String chatBackground;

    private static ConfigManger configManger;

    private ConfigManger() {
        System.out.println("初始化，从数据库中读取所有设置项");

        //假设当前数据库中文字大小为【中】，聊天背景为【风景】
        fontSize = "中";
        chatBackground = "风景";
    }

    public static ConfigManger getInstance() {
        if (configManger == null) {
            synchronized (ConfigManger.class) {
                if (configManger == null) {
                    configManger = new ConfigManger();
                }
            }
        }
        return configManger;
    }

    public String getFontSize() {
        return fontSize;
    }

    public void setFontSize(String fontSize) {
        this.fontSize = fontSize;
        System.out.println("将数据库中文字大小设置为： " + fontSize);
    }

    public String getChatBackground() {
        return chatBackground;
    }

    public void setChatBackground(String chatBackground) {
        this.chatBackground = chatBackground;
        System.out.println("将数据库中聊天背景设置为： " + chatBackground);
    }


}
